package com.project.dao.impl;

import java.util.List;
import java.util.UUID;

import com.project.dao.ArticleDao;
import com.project.dao.bean.Article;

public class ArticleDaoImpl extends BaseDaoImpl implements ArticleDao 
{

	@Override
	public void update(Article article) throws Exception 
	{
		this.getSqlMapClient().update("updateArticle", article);
	}

	@Override
	public void save(Article article) throws Exception 
	{
		UUID uuid = UUID.randomUUID();
		article.setArticle_id(uuid.toString());
		this.getSqlMapClient().insert("saveArticle", article);
	}

	@Override
	public List<Article> getArticle() throws Exception 
	{
		List<Article> list = this.getSqlMapClient().queryForList("getNewsTitle");
        return list;
	}

	@Override
	public void delete(Article article) throws Exception 
	{
		this.getSqlMapClient().update("deleteArticle", article);
	}

	@Override
	public List<Article> getArticle(Article article) throws Exception 
	{
		List<Article> list = this.queryWithPg("queryArticleByPg", article);
		return list;
	}

	@Override
	public Article getArticleById(Article article) throws Exception 
	{
		return (Article)this.getSqlMapClient().queryForObject("getArticleById",article);
	}

	@Override
	public void saveExl(Article article) throws Exception 
	{
		UUID uuid = UUID.randomUUID();
		article.setArticle_id(uuid.toString());
		this.getSqlMapClient().insert("saveArticleByExl", article);
	}
}
